/*
 * Austrian Lotto Problem
 *
 * Author: Yue ZHAO
 *
 * Language: C++
 */

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <cstdlib>  // int rand (void)
#include <ctime>

using namespace std;

class AustrianLotto {
public:
  vector<int> evaluate(string drawing, vector<string> picks) {
	vector<int> ret(7, 0);

	istringstream buffer(drawing);
	vector<int> v(6, 0);
    
    for (int i=0; i<6; i++) 
      buffer >> v[i];

    for (int i=0; i<picks.size(); i++) {
      buffer.clear();
      buffer.str(picks[i]);
      
      int count = 0;
      for (int j=0; j<6; j++) {
        int a;
        buffer >> a;
        
        for (int k=0; k<6; k++) {
          if (a == v[k]) {
            count ++;
            break;
          }
        }
      }

      ret[count] ++; 
    }

    return ret;
  }

};


// generate random draws (strings)
class LottoTester {
public:
	LottoTester() {
	    srand(time(NULL));
		for (int i=1; i<=45; i++)
			num.push_back(i);
	}

	string draw() {
		stringstream ss;
		for (int i=0; i<6; i++) {
			int inx = (rand()) % 45;
			int tmp = num[i];

			num[i] = num[inx];
			num[inx] = tmp;
		}

		ss << num[0];
		for (int i=1; i<6; i++) {
			ss << " " << num[i];
		}

		return ss.str();
	}

private:
	vector<int> num;

};


int main(int argc, char **argv) {

  LottoTester ts;
  string drawing(ts.draw());
  vector<string> picks;
  
  int ndraw = (rand() % 50 + 1);
  for (int i=0; i<ndraw; i++)
	picks.push_back(ts.draw());
  
  AustrianLotto al;
  vector<int> ret = al.evaluate(drawing, picks);

  int sum = 0;
  for (int i=0; i<ret.size(); i++) {
	sum += ret[i];
	cout << ret[i] << " ";
  }
  cout << endl;

  return 0;
}

